/*   1:    */ package tt.dz.web.controller.manager;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.util.ArrayList;
/*   5:    */ import java.util.HashMap;
/*   6:    */ import java.util.LinkedHashMap;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import javax.servlet.http.HttpServletRequest;
/*  11:    */ import javax.servlet.http.HttpServletResponse;
/*  12:    */ import org.apache.commons.collections.CollectionUtils;
/*  13:    */ import org.springframework.stereotype.Controller;
/*  14:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  15:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  16:    */ import tt.dz.biz.service.batchpay.BatchPayService;
/*  17:    */ import tt.dz.biz.service.common.CommonService;
import tt.dz.common.DzConstants;
/*  18:    */ import tt.dz.common.DzConstants.bizSysCode;
/*  19:    */ import tt.dz.common.DzConstants.payState;
/*  20:    */ import tt.dz.common.DzConstants.userType;
/*  21:    */ import tt.dz.common.ExcelUtill;
/*  22:    */ import tt.dz.common.LogUtil;
/*  23:    */ import tt.dz.vo.BatchPayVO;
/*  24:    */ import tt.dz.vo.OrderServiceVO;
/*  25:    */ import tt.dz.vo.ResponseModle;
/*  26:    */ import tt.dz.vo.TranInfoVO;
/*  27:    */ import tt.dz.web.controller.BaseController;
/*  28:    */ 
/*  29:    */ @Controller
/*  30:    */ public class BatchPayController
/*  31:    */   extends BaseController
/*  32:    */ {
/*  33:    */   @Resource(name="batchPayService")
/*  34:    */   private BatchPayService batchPayService;
/*  35:    */   @Resource(name="commonService")
/*  36:    */   private CommonService commonService;
/*  37:    */   
/*  38:    */   @RequestMapping(value={"/listPayerSel"}, produces={"application/json;charset=UTF-8"})
/*  39:    */   @ResponseBody
/*  40:    */   public String listPayerSel()
/*  41:    */     throws Exception
/*  42:    */   {
/*  43: 53 */     ResponseModle responseModle = null;
/*  44: 54 */     Map<String, String> paySelMap = this.batchPayService.queryPayerSelMap(null);
/*  45: 55 */     responseModle = new ResponseModle("success", paySelMap);
/*  46: 56 */     return JSON.toJSONString(responseModle);
/*  47:    */   }
/*  48:    */   
/*  49:    */   @RequestMapping(value={"/listBatchPay"}, produces={"application/json;charset=UTF-8"})
/*  50:    */   @ResponseBody
/*  51:    */   public String listBatchPay(String payer, String batchMonth)
/*  52:    */   {
/*  53: 69 */     ResponseModle responseModle = null;
/*  54: 70 */     Map<String, Object> params = new HashMap();
/*  55: 71 */     params.put("payer", payer);
/*  56: 72 */     params.put("batchMonth", batchMonth);
/*  57:    */     try
/*  58:    */     {
/*  59: 74 */       List<BatchPayVO> batchPayList = this.batchPayService.queryBatchPay(params);
/*  60: 75 */       responseModle = new ResponseModle("success", batchPayList);
/*  61:    */     }
/*  62:    */     catch (Exception e)
/*  63:    */     {
/*  64: 77 */       LogUtil.error("查询统付批次异常", e);
/*  65: 78 */       responseModle = new ResponseModle("error", "查询统付批次异常");
/*  66:    */     }
/*  67: 80 */     return JSON.toJSONString(responseModle);
/*  68:    */   }
/*  69:    */   
/*  70:    */   @RequestMapping({"/exportExcelBatchPay"})
/*  71:    */   @ResponseBody
/*  72:    */   public byte[] exportExcelBatchPay(String payer, String batchMonth, HttpServletResponse response)
/*  73:    */   {
/*  74: 91 */     byte[] excel = null;
/*  75: 92 */     Map<String, Object> params = new HashMap();
/*  76: 93 */     params.put("payer", payer);
/*  77: 94 */     params.put("batchMonth", batchMonth);
/*  78:    */     try
/*  79:    */     {
/*  80: 96 */       List<BatchPayVO> batchPayList = this.batchPayService.queryBatchPay(params);
/*  81: 97 */       List<BatchPayVO> payList = new ArrayList();
/*  82: 98 */       if (CollectionUtils.isNotEmpty(batchPayList)) {
/*  83: 99 */         for (BatchPayVO vo : batchPayList)
/*  84:    */         {
/*  85:100 */           if (DzConstants.payState.WAITING_FOR_PAYING.value().equals(vo.getState())) {
/*  86:101 */             vo.setStateDesc(DzConstants.payState.WAITING_FOR_PAYING.getDesc());
/*  87:    */           }
/*  88:103 */           if (DzConstants.payState.PAY_SUCCESS.value().equals(vo.getState())) {
/*  89:104 */             vo.setStateDesc(DzConstants.payState.PAY_SUCCESS.getDesc());
/*  90:    */           }
/*  91:106 */           payList.add(vo);
/*  92:    */         }
/*  93:    */       }
/*  94:109 */       Object fieldMap = new LinkedHashMap();
/*  95:110 */       ((LinkedHashMap)fieldMap).put("付款方", "payerName");
/*  96:111 */       ((LinkedHashMap)fieldMap).put("收款方", "receiverName");
/*  97:112 */       ((LinkedHashMap)fieldMap).put("服务", "serviceName");
/*  98:113 */       ((LinkedHashMap)fieldMap).put("金额(元)", "totalFee");
/*  99:114 */       ((LinkedHashMap)fieldMap).put("笔数", "totalCount");
/* 100:115 */       ((LinkedHashMap)fieldMap).put("月份", "batchMonth");
/* 101:116 */       ((LinkedHashMap)fieldMap).put("状态", "stateDesc");
/* 102:    */       
/* 103:118 */       excel = ExcelUtill.getXLSByteArray("统付报表", (LinkedHashMap)fieldMap, payList);
/* 104:    */       
/* 105:120 */       response.setHeader("Content-Disposition", "attachment;fileName=统付报表.xls");
/* 106:121 */       response.setHeader("Content-Transfer-Encoding", "binary");
/* 107:122 */       response.setContentType("application/vnd.ms-excel; charset=utf-8");
/* 108:    */     }
/* 109:    */     catch (Exception e)
/* 110:    */     {
/* 111:124 */       LogUtil.error("导出统付批次异常", e);
/* 112:    */     }
/* 113:126 */     return excel;
/* 114:    */   }
/* 115:    */   
/* 116:    */   @RequestMapping(value={"/querySettlementServiceForBatchPay"}, produces={"application/json;charset=UTF-8"})
/* 117:    */   @ResponseBody
/* 118:    */   public String querySettlementServiceForBatchPay(HttpServletRequest rq)
/* 119:    */   {
/* 120:137 */     ResponseModle responseModle = null;
/* 121:138 */     String serviceNo = rq.getParameter("serviceNo");
/* 122:    */     try
/* 123:    */     {
/* 124:140 */       List<OrderServiceVO> serviceList = this.batchPayService.querySettlementServiceForBatchPay(serviceNo);
/* 125:141 */       responseModle = new ResponseModle("success", serviceList);
/* 126:    */     }
/* 127:    */     catch (Exception e)
/* 128:    */     {
/* 129:143 */       LogUtil.error("查询统付批次异常", e);
/* 130:144 */       responseModle = new ResponseModle("error", "查询统付批次异常");
/* 131:    */     }
/* 132:146 */     return JSON.toJSONString(responseModle);
/* 133:    */   }
/* 134:    */   
/* 135:    */   @RequestMapping(value={"/saveReceivable"}, produces={"application/json;charset=UTF-8"})
/* 136:    */   @ResponseBody
/* 137:    */   public String getReceivable(HttpServletRequest rq)
/* 138:    */   {
/* 139:157 */     ResponseModle responseModle = null;
/* 140:158 */     BatchPayVO batchPayVO = (BatchPayVO)JSON.parseObject(rq.getParameter("receivable"), BatchPayVO.class);
/* 141:    */     try
/* 142:    */     {
/* 143:160 */       LogUtil.debug("batchPayVO为：" + batchPayVO);
/* 144:161 */       TranInfoVO tranInfo = new TranInfoVO();
/* 145:162 */       tranInfo.setServiceNo(batchPayVO.getSettlementServiceNo());
/* 146:163 */       tranInfo.setPayStateCode(DzConstants.payState.PAY_SUCCESS.value());
/* 147:164 */       tranInfo.setPayTypeCode(batchPayVO.getPayTypeCode());
/* 148:165 */       tranInfo.setChannelCode(batchPayVO.getChannelCode());
/* 149:166 */       tranInfo.setPaymentAmount(batchPayVO.getTotalFee());
/* 150:167 */       tranInfo.setAppId(DzConstants.bizSysCode.MAIN_SERVER.value());
/* 151:    */       
/* 152:169 */       tranInfo.setPayer(batchPayVO.getPayer());
/* 153:170 */       tranInfo.setPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
/* 154:171 */       tranInfo.setOriginalPayer(batchPayVO.getPayer());
/* 155:172 */       tranInfo.setOriginalPayerType(DzConstants.userType.MERCHANT_CUSTOMER.value());
/* 156:173 */       tranInfo.setReceiver(batchPayVO.getReceiver());
/* 157:174 */       tranInfo.setReceiverType(DzConstants.userType.MERCHANT_CUSTOMER.value());
/* 158:175 */       this.batchPayService.saveReceivable(batchPayVO, tranInfo);
/* 159:176 */       responseModle = new ResponseModle("success", null);
/* 160:    */     }
/* 161:    */     catch (Exception e)
/* 162:    */     {
/* 163:178 */       LogUtil.error("保存收款信息异常", e);
/* 164:179 */       responseModle = new ResponseModle("error", "保存收款信息异常");
/* 165:    */     }
/* 166:181 */     return JSON.toJSONString(responseModle);
/* 167:    */   }
/* 168:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.manager.BatchPayController
 * JD-Core Version:    0.7.0.1
 */